package es.andresimon.portfolio.web;

import org.springframework.roo.addon.web.mvc.controller.RooWebScaffold;
import es.andresimon.portfolio.security.PortfolioUser;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.mail.MailSender;
import org.springframework.beans.factory.annotation.Autowired;

@RooWebScaffold(path = "portfoliousers", formBackingObject = PortfolioUser.class)
@RequestMapping("/portfoliousers")
@Controller
public class PortfolioUserController {

    @Autowired
    private transient MailSender mailTemplate;

    public void sendMessage(String mailFrom, String subject, String mailTo, String message) {
        org.springframework.mail.SimpleMailMessage simpleMailMessage = new org.springframework.mail.SimpleMailMessage();
        simpleMailMessage.setFrom(mailFrom);
        simpleMailMessage.setSubject(subject);
        simpleMailMessage.setTo(mailTo);
        simpleMailMessage.setText(message);
        mailTemplate.send(simpleMailMessage);
    }
}
